{template 'system/common/header'}
<div class="dm-subnav">
    <div class="subnav-title">幻灯片管理</div>
    <ul>
        <li {if $operation == 'list'}class="active"{/if}><a href="{php echo $this->createWebUrl('adv', array('op' => 'list'))}">幻灯片列表</a></li>
        <li {if $operation == 'add' && empty($id)}class="active"{/if}><a href="{php echo $this->createWebUrl('adv', array('op' => 'add'))}">添加幻灯片</a></li>
        {if $operation == 'add' && !empty($id)}<li class="active"><a href="{php echo $this->createWebUrl('adv', array('op' => 'add','id'=>$id))}">修改幻灯片</a></li>{/if}
        
    </ul>
</div>
<style type="text/css">
.must::before {
    content: "*";
    position: absolute;
    right: 0px;
    top: 10px;
    color: #f30;
    font-size: 12px;
}
.control-label{padding-right: 20px !important;}
</style>
<div class="dm-container">
<div class="dm-content">
{if $operation == 'list'}

{if empty($list)}
<div class="panel we7-panel panel-default">
    <div class="panel-body" style="text-align: center;padding:30px;">
        暂时没有任何幻灯片!!
    </div>
</div>
{else}
<form action="" method="post">
    <table class="table we7-table table-hover table-responsive">
        <thead class="navbar-inner">
            <tr>
                <th style="width:50px;">ID</th>
                <th style="width:100px">显示顺序</th>
                <th>标题</th>
                <th>连接</th>
                <th>状态</th>
                <th style="width: 250px;">操作</th>
            </tr>
        </thead>
        <tbody id="sort">
        	{loop $list $advItem}
        	<tr>
                <td style="width:50px;">{$advItem['id']}</td>
                <td style="width:100px"><input type="text" name="sortid[{$advItem['id']}]" class="form-control" value="{$advItem['sortid']}"></td>
                <td><img src="{php echo tomedia($advItem['adv_img'])}" onerror="this.src='../web/resource/images/nopic.jpg'" style="width:30px;height:30px;padding:1px;border:1px solid #ccc"> {$advItem['adv_title']}</td>
                <td>{$advItem['adv_url']}</td>
                <td>{if $advItem['adv_isshow']}<span class="label label-success">显示</span>{else}<span class="label label-default">隐藏</span>{/if}</td>
                <td style="text-align:left;">
                    <a href="{php echo $this->createWebUrl('adv',array('op'=>'add','id'=>$advItem['id']))}" class="btn btn-default btn-sm" title="修改"><i class="fa fa-edit"></i> 修改</a>
                    <a data-toggle="ajaxRemove" href="{php echo $this->createWebUrl('adv',array('op'=>'delete','id'=>$advItem['id']))}" class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" title="删除"><i class="fa fa-trash"></i> 删除</a>
                </td>
            </tr>
            
        	{/loop}
            <tr>
                <td colspan='6'>
                      <input type="hidden" name="token" value="{$_W['token']}" />
                   
                      <input name="submit" type="submit" class="btn btn-primary" value="提交排序">
                    
                </td>
            </tr>
        </tbody>
	</table>
    {$pager}
</form>
{/if}
{elseif $operation == 'add'}
<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit="return formcheck();" style="margin-top: 15px;">
<input type="hidden" name="id" value="{$advItem['id']}">
<div class="panel panel-default">
<div class="panel-heading">{if $advItem['id']}编辑{else}新增{/if}幻灯片</div>
<div class="panel-body">
    <div class="form-group">
        <label class="col-sm-2 control-label">排序</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="displayorder" class="form-control" value="{$advItem['sortid']}">
            <span class="help-block">数字越大，排名越靠前</span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label must">幻灯片名称</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="adv_title" class="form-control" value="{$advItem['adv_title']}" required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">幻灯片图片</label>
        <div class="col-sm-9 col-xs-12">
			{php echo tpl_form_field_image('adv_img',$advItem['adv_img']);}
			<span class="help-block">请将所有幻灯片图片尺寸保持一致</span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">幻灯片链接</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="adv_url" class="form-control" value="{$advItem['adv_url']}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">状态</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline" style="padding-left: 20px;">
                <input type="radio" name="enabled" value="1" {if $advItem['adv_isshow'] == 1} checked="checked" {/if}> 显示
            </label>
            <label class="radio-inline" style="padding-left: 20px;">
                <input type="radio" name="enabled" value="0" {if $advItem['adv_isshow'] == 0} checked="checked" {/if}> 隐藏
            </label>
        </div>
    </div>
    <div class="form-group"></div>
    <div class="form-group">
        <label class="col-sm-2 control-label"></label>
        <div class="col-sm-9 col-xs-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary">
            <input type="hidden" name="token" value="{$_W['token']}" />
           <input type="button" name="back" onclick="history.back()" style="margin-left:10px;" value="返回列表" class="btn btn-default">
        </div>
    </div>
</div>
</div>
</form>
{/if}
</div>
</div>
{template 'system/common/footer'}